package com.agent.commons.utils;

import cn.hutool.core.util.HexUtil;
import cn.hutool.crypto.symmetric.SM4;

/**
 * sm4加解密工具类
 */
public class Sm4Util {
    /**
     * Sm4加解密密钥
     */
    private static final String SM4_KEY = "1234567890ABCDEF1234567890ABCDEF";

    /**
     * Sm4加密
     * @param content
     * @return
     */
    public static String encrypt(String content) {
        return new SM4(HexUtil.decodeHex(SM4_KEY)).encryptHex(content);
    }

    /**
     * Sm4解密
     * @param content
     * @return
     */
    public static String decrypt(String content) {
        return new SM4(HexUtil.decodeHex(SM4_KEY)).decryptStr(content);
    }
}
